<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!--<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />-->
<meta http-equiv="Access-Control-Allow-Origin" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link href="../../css/style.css" rel="stylesheet" type="text/css" />
<!--  <script src="https://unpkg.com/axios/dist/axios.min.js"></script>-->
<script type="text/javascript" src="../../js/jquery.js"></script>
<script type="text/javascript" src="../../js/axios.js"></script>
<script type="text/javascript" src="../../js/api.js"></script>
<link rel="stylesheet" href="../../layui/css/layui.css">
<script type="text/javascript" src="../../layui/layui.js"></script>
</head>

<body>
<div class="place"> <span>位置：</span>
  <ul class="placeul">
    <li>数据统计</li>
    <li>客户销量统计</li>
    <li>基本内容</li>
  </ul>
</div>
<div class="rightinfo">
  <form method="post" id="search_condition">
    <ul class="tools">
      <li> 所属区域：
        <select name="province" id="province">
          <option value="0">请选择省份</option>
          <option>北京</option>
          <option>江苏</option>
          <option>天津</option>
        </select>
        <select name="city" id="city">
          <option value="0">请选择城市</option>
          <option value="1">北京</option>
          <option value="2">南京</option>
          <option value="3">天津</option>
        </select>
      </li>
      <li> 客户姓名:
        <input name="customnamelike" type="text" />
      </li>
      <li> 时间:
        <input name="startime" type="text" />-<input  name="endtime" type="text" />
      </li>
<!--onclick="window.location.href='salesStatis.html'"-->
      <li class="subBut" id="subBut" type="button" onclick="load()"><img src="../../images/t06.png" />查询</li>
    </ul>
    <table class="tablelist">
      <thead>
        <tr>
          <th>序号</th>
          <th>客户姓名</th>
          <th>所属区域</th>
          <th>订购单数量</th>
          <th>金额</th>
          <th>订购单明细</th>
        </tr>
      </thead>
      <tbody id="tb">
        <!--<tr>
          <td>1</td>
          <td>王金平</td>
          <td>江苏南京</td>
          <td>5</td>
          <td>￥9,876,582</td>
          <td>
          	<a href="salesView.html" class="tablelink">查看详情</a>
          </td>
        </tr>-->

      </tbody>
    </table>
    <!--原本项目给的默认分页，假的分页-->
    <div class="pagin" id="page">
<!--      <div class="message">共<i class="blue">1256</i>条记录，当前显示第&nbsp;<i class="blue">2&nbsp;</i>页</div>-->
<!--      <ul class="paginList">-->
<!--        <li class="paginItem"><a href="javascript:;"><span class="pagepre"></span></a></li>-->
<!--        <li class="paginItem"><a href="javascript:;">1</a></li>-->
<!--        <li class="paginItem current"><a href="javascript:;">2</a></li>-->
<!--        <li class="paginItem"><a href="javascript:;">3</a></li>-->
<!--        <li class="paginItem"><a href="javascript:;">4</a></li>-->
<!--        <li class="paginItem"><a href="javascript:;">5</a></li>-->
<!--        <li class="paginItem more"><a href="javascript:;">...</a></li>-->
<!--        <li class="paginItem"><a href="javascript:;">10</a></li>-->
<!--        <li class="paginItem"><a href="javascript:;"><span class="pagenxt"></span></a></li>-->
<!--      </ul>-->
    </div>
  </form>
</div>
<script type="text/javascript">
  var condition;
  var totalcount;
  var pagesize = 8;
  var pagenum = 1;

  $(function () {
      load();
      addressMenuInitOfDefault($("#province"), $("#city"), 0, 0)
  })
  function load() {
    condition = $("#search_condition").serializeArray();
    for (let i = condition.length;i>3;i--){
     // if (i==3 || i==4){
       let v = condition[i-1];
       if (v.value==""){
         // condition.pop(); //pop 删除数组最后一个元素
         condition.splice(i-1,1)
       }
    //    // console.log("value:"+v.value)
     }


    let str = "";
    axiosJson("get", "/census/queryCustomBaseInfo", condition, {pagenum:pagenum,pagesize:pagesize}).then(res => {

      totalcount = res.data.totalCount;
      pagesize = res.data.pageSize;
      pagenum = res.data.pageNum;
      /*console.log(res)*/
      res = res.data;

      for (let i = 0; i < res.data.length; i++) {
        var rel = res.data[i];
        var customid = res.data[i].customid;
        /*console.log(customid)*/
        str += '<tr>\n' +
                '          <td>' + (i + 1) + '</td>\n' +
                '          <td>' + rel.customname + '</td>\n' +
                '          <td>' +(rel.provincename+rel.cityname) + '</td>\n' +
                '          <td>' + rel.ordernum + '</td>\n' +
                '          <td>￥' + rel.money + '</td>\n' +
                '          <td>\n' +
                '             <a href="salesView.html?id='+customid+'" class="tablelink">查看详情</a>\n' +
                '          </td>\n' +
                '        </tr>';
      }
      $("#tb").html(str);
      $('.tablelist tbody tr:odd').addClass('odd');

      /*分页 经过李哥的教导，会了一点*/
      layui.use("laypage", function () {
        var laypage = layui.laypage;
        laypage.render({
          elem: "page",                       //页码所放的位置，div标签的id
          count: totalcount,             	    //总记录数
          limit: pagesize,                    //每页的数据
          limits: [5, 8, 12],                 //每页可访问的数据量，可供用户选择
          curr: pagenum,                      //当前页
          layout: ['prev', 'page', 'next', 'limit', 'count'],
          //layout是改变分页布局的变量 prev:上一页 page:页码 next:下一页 limit:改分页长度下拉框 count:显示数据总量
          jump: function (obj, first) {		//监听分页按钮，按下时被调用
            pagenum = obj.curr		//获取改变的分页信息   就是说你按了2那么就会获取2，按3则获取3
            pagesize = obj.limit
            if (!first) {
              load(pagenum, pagesize);	//重新调用自己的加载页面的函数
            }
          }
        })
      })
    })
  };



  /*从后端显示，暂时还没实现，先空着*/
/*  function loadCustomInfo() {
      // alert("进了subBut")

      condition = $("#search_condition").serializeArray();



    for (let i = condition.length;i>3;i--){
      // if (i==3 || i==4){
      let v = condition[i-1];
      if (v.value==""){
        // condition.pop(); //pop 删除数组最后一个元素
        condition.splice(i-1,1)
      }
      // console.log("value:"+v.value)
    }
      // alert(condition)
      /!*console.log("condition:"+condition)*!/
      let str = "";
      axiosJson("get","/census/queryCustomBaseInfo",condition,{pagenum:pagenum, pagesize:pagesize}).then(res => {

        res = res.data;
        pagesize=res.pageSize;
        pagenum=res.pageNum;
        totalcount=res.totalCount;
        /!*console.log(res)*!/

        for (let i = 0;i < res.data.length;i++){
          var rel = res.data[i];
          var customid = res.data[i].customid;
        /!*  console.log(customid)
          console.log("开始拼接");*!/
          str+='<tr>\n' +
                  '          <td>'+(i+1)+'</td>\n' +
                  '          <td>'+rel.customname+'</td>\n' +
                  '          <td>'+rel.provincename+rel.cityname+'</td>\n' +
                  '          <td>'+rel.ordernum+'</td>\n' +
                  '          <td>￥'+rel.money+'</td>\n' +
                  '          <td>\n' +
                  '             <a href="salesView.html?id='+customid+'" class="tablelink">查看详情</a>\n' +
                  '          </td>\n' +
                  '        </tr>';
        }
        /!*console.log("拼接结束");*!/
        $("#tb").html(str);
        /!*console.log("返回值来了");*!/

        /!*分页 经过李哥的教导，会了一点*!/
        layui.use("laypage", function () {
          var laypage = layui.laypage;
          laypage.render({
            elem: "page",                       //页码所放的位置，div标签的id
            count: totalcount,             	    //总记录数
            limit: pagesize,                    //每页的数据
            limits: [5, 8, 12],                 //每页可访问的数据量，可供用户选择
            curr: pagenum,                      //当前页
            layout: ['prev', 'page', 'next', 'limit', 'count'],
            //layout是改变分页布局的变量 prev:上一页 page:页码 next:下一页 limit:改分页长度下拉框 count:显示数据总量
            jump: function (obj, first) {		//监听分页按钮，按下时被调用
              pagenum = obj.curr		//获取改变的分页信息   就是说你按了2那么就会获取2，按3则获取3
              pagesize = obj.limit
              if (!first) {
                loadCustomInfo(pagenum, pagesize);	//重新调用自己的加载页面的函数
              }
            }
          })
        })
      })
    };*/

    $('.tablelist tbody tr:odd').addClass('odd');
</script>
</body>
</html>
